<template>
  <div id="backgrounddemo">
  <div id="login-container">
    <div style="text-align: center;height: 50px; font-size: 25px">
        欢迎您！请登录
    </div>
    <el-form ref="form" :model="form" label-width="100px" >
      <el-form-item label="账号" >
        <el-tooltip class="box-item" effect="dark" content="应为11位手机号" placement="top-start">
          <el-input v-model="form.username" placeholder="请输入手机号" maxlength="11" minlength="11"></el-input>
        </el-tooltip>

      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.password" placeholder="请输入密码" type="password" show-password></el-input>
      </el-form-item>
      <el-form-item style="marginLeft:100px">
        <el-button type="success" @click="login">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
  </div>
</template>

<script>
import router from "@/router";
import axios from "axios";

export default {
  name: "Login",
  data() {
    return {
      form: {
        username: "",
        password: ""
      }
    }
  },
  methods: {
     login() {
       axios.post("/api/login", this.form).then((res) => {
         if(res.data.code==20051){
           alert(res.data.msg);
           router.push("/medical");
         }else{
           alert(res.data.msg);
           this.form={};
         }
       });
    }
  }
}
</script>

<style scoped>

body{
  margin: 0;
}
#login-container{
  width: 400px;
  height: 290px;
  background: azure;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -220px;
  margin-top: -170px;
  border-radius: 5px;
  padding-top: 40px;
  padding-right: 40px;
}
#backgrounddemo{
  background: url("@/assets/img/back3.jpeg");
  width: 100%;
  height: 100%;
  position: fixed;
  background-size: 100% 100%;
}
</style>